<template>
  <div class="app-container">
    <el-table
      :data="list"
      row-key="ProductKindID"
      :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
      border
      fit
      highlight-current-row
      class="infotable"
      style="margin:-10px -20px 0px -20px;"
      @row-click="onRowClick"
    >
      <el-table-column label="类别ID" width="auto">
        <template slot-scope="scope">{{scope.row.ProductKindID}}</template>
      </el-table-column>
      <el-table-column label="类别名" width="auto">
        <template slot-scope="scope">{{scope.row.KindName}}</template>
      </el-table-column>
      <el-table-column label="顺序" width="auto">
        <template slot-scope="scope">{{scope.row.OrderNum}}</template>
      </el-table-column>
      <el-table-column label="状态" width="auto">
        <template slot-scope="scope">
          <span v-if='scope.row.KindState==1'>正常</span>
          <span v-else style="color:#888;">隐藏</span>
        </template>
      </el-table-column>
      <el-table-column label="登记人" width="auto">
        <template slot-scope="scope">{{scope.row.RegFullName}}</template>
      </el-table-column>
      <el-table-column label="登记时间" width="auto">
        <template slot-scope="scope">{{scope.row.RegDateTime}}</template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
//   import shared from '../../../../shared';
import {
  getProductKindEditList //url:'/product/GetProductKindEditList'
} from "@/api/product";
export default {
  props:{
    activeTab:{type:String,default:'gift'}
  },
  data() {
    return {
      list: []
    };
  },
  created() {
    this.GetList();
  },
  watch:{
    activeTab:function(){
      this.GetList();
    }
  },
  methods: {
    onRowClick(row, column, event){
      this.$emit('row-click',row);
    },
    formatDateTime(datetime) {
      return shared.formatDateTime(datetime);
    },
    handleSizeChange(val) {
      this.data.page_size = val;
      this.getList();
    },
    handleCurrentChange(val) {
      this.data.page_index = val;
      this.getList();
    },
    Refresh() {
      this.GetList();
    },
    GetList() {
      let data = {
        type: this.$props.activeTab=='gift'?1:2,
        level: 1
      };
      getProductKindEditList(data).then(r => {
        if (r.code == 0) {
          let temp;
          let tList=[];
          r.data.forEach(element => {
            element.record.children=element.child;
            tList.push(element.record);            
          });
          this.list = tList;
        } else {
          this.$message.error("获取种类列表出错！原因：" + r.msg);
        }
      });
    },
  }
};
</script>

<style scoped>
</style>
